//
//  MoFullBodyDialog.swift
//  soapp
//
//  Created by zhuxietong on 2021/3/19.
//

import Foundation
import Eelay

open class MoFullBodyDialog<Body:DialogContent>:MoDialog<Body>{

         open override func updateModalHeight()  {
            if contentHeight > 0 {
                
                var modalHeight = contentHeight
                let limitHeight = Sheight - MoUIAdapter.safeInset.top - MoUIAdapter.safeInset.top - style.offsetY - 60
                if type == .sheet{
                     modalHeight = modalHeight + MoUIAdapter.safeInset.bottom
                }
                if modalHeight > limitHeight{
                    modalHeight = limitHeight
                    tableView.isScrollEnabled = true
                }else{
                    tableView.isScrollEnabled = false
                }
                heightConstraint.constant = modalHeight

                tableNode.performBatch(animated: false) {
                    
                } completion: { _ in
                    
                }
                modalView.setNeedsLayout()
                modalView.layoutIfNeeded()
                            
                
            }
        }

        
        open override func layTable(tableView: UIView) {
            jo_contentView.setEeLays(lays: [
                [tableView,[ee.T.L.B.R]],
            ])
            node.clipsToBounds = false
            node.updatedSize = {
                [weak self] size in
                guard let `self` = self else {
                    return
                }
                self.contentHeight = size.height
            }
            node.alert = self
        }
                
        
        open override func layoutCloseBt() {

        }
        open override func viewDidLoad() {
            super.viewDidLoad()
        }
    }

